home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Libraries / Framework / Sources / UScriptableObject.cp < prev    next >
Encoding:
Text File  |  1996-04-03  |  40.9 KB  |  1,285 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // UScriptableObject.cp
  3. // Copyright © 1988-96 by Apple Computer, Inc. All rights reserved.
  4. //----------------------------------------------------------------------------------------
  5.  
  6. #ifndef __USCRIPTABLEOBJECT__
  7. #include "UScriptableObject.h"
  8. #endif
  9.  
  10. // MacApp
  11.  
  12. #ifndef __UBEHAVIOR__
  13. #include "UBehavior.h"
  14. #endif
  15.  
  16. #ifndef __UCOMMANDHANDLER__
  17. #include "UCommandHandler.h"
  18. #endif
  19.  
  20. #ifndef __UCOREERRORMGR__
  21. #include "UCoreErrorMgr.h"
  22. #endif
  23.  
  24. #ifndef __UCOREGLOBALS__
  25. #include "UCoreGlobals.h"
  26. #endif
  27.  
  28. #ifndef __UCOREUTILITIES__
  29. #include "UCoreUtilities.h"
  30. #endif
  31.  
  32. #ifndef __UDISPATCHER__
  33. #include "UDispatcher.h"
  34. #endif
  35.  
  36. //    #ifndef __UERRORMGR__
  37. //    #include "UErrorMgr.h"
  38. //    #endif
  39.  
  40. //    #ifndef __UFILE__
  41. //    #include "UFile.h"
  42. //    #endif
  43.  
  44. #ifndef __ULISTITERATOR__
  45. #include "UListIterator.h"
  46. #endif
  47.  
  48. #ifndef __UMACAPPGLOBALS__
  49. #include "UMacAppGlobals.h"
  50. #endif
  51.  
  52. #ifndef __UMACAPPUTILITIES__
  53. #include "UMacAppUtilities.h"
  54. #endif
  55.  
  56. #if qAttachable
  57.     #ifndef __UOSASCRIPT__
  58.     #include "UOSAScript.h"
  59.     #endif
  60. #endif
  61.  
  62. #ifndef __USCRIPTING__
  63. #include "UScripting.h"
  64. #endif
  65.  
  66. // Toolbox
  67.  
  68. #ifndef __AEPACKOBJECT__
  69. #include <AEPackObject.h>
  70. #endif
  71.  
  72. #ifndef __ASDEBUGGING__
  73. #include <ASDebugging.h>
  74. #endif
  75.  
  76. #ifndef __ASREGISTRY__
  77. #include <ASRegistry.h>
  78. #endif
  79.  
  80. #ifndef __OSAGeneric__
  81. #include <OSAGeneric.h>
  82. #endif
  83.  
  84. #ifndef __RESOURCES__
  85. #include <Resources.h>
  86. #endif
  87.  
  88. //========================================================================================
  89. // CLASS MScriptableObject
  90. //========================================================================================
  91. #undef Inherited
  92.  
  93. #pragma segment MAScriptingRes
  94. MA_DEFINE_CLASS_M0(MScriptableObject);
  95.  
  96. //----------------------------------------------------------------------------------------
  97. // MScriptableObject constructor
  98. //----------------------------------------------------------------------------------------
  99. #pragma segment ConstructorRes
  100.  
  101. MScriptableObject::MScriptableObject()
  102.     : fOMClassID(typeNull)
  103. {
  104. }
  105.  
  106. MScriptableObject::MScriptableObject(DescType myClassID)
  107.     : fOMClassID(myClassID)
  108. {
  109. }
  110.  
  111. #if qAttachable
  112.  
  113. //----------------------------------------------------------------------------------------
  114. // MScriptableObject destructor
  115. //----------------------------------------------------------------------------------------
  116. #pragma segment MADestructorRes
  117.  
  118. MScriptableObject::~MScriptableObject()
  119. {
  120.     FreeOSAScript();
  121. }
  122.  
  123. #endif // qAttachable
  124.  
  125. //----------------------------------------------------------------------------------------
  126. // MScriptableObject::GetOMClass
  127. //----------------------------------------------------------------------------------------
  128. #pragma segment MAOSLDispatch
  129.  
  130. DescType MScriptableObject::GetOMClass()
  131. {
  132.     return fOMClassID;
  133. }
  134.  
  135. //----------------------------------------------------------------------------------------
  136. // MScriptableObject::GetSpecifierForm
  137. //----------------------------------------------------------------------------------------
  138. #pragma segment MAOSLDispatch
  139.  
  140. DescType MScriptableObject::GetSpecifierForm()
  141. {
  142.     return formAbsolutePosition;
  143. }
  144.  
  145. //----------------------------------------------------------------------------------------
  146. // MScriptableObject::CountContainedObjects
  147. //----------------------------------------------------------------------------------------
  148. #pragma segment MAOSLDispatch
  149.  
  150. long MScriptableObject::CountContainedObjects(DescType/* desiredType */ )
  151. {
  152.     // Returns the number of objects ofType that this object contains.
  153.     return 0;
  154. }
  155.  
  156. //----------------------------------------------------------------------------------------
  157. // MScriptableObject::CompareScriptableObjects
  158. //----------------------------------------------------------------------------------------
  159. #pragma segment MAOSLDispatch
  160.  
  161. Boolean MScriptableObject::CompareScriptableObjects(DescType operation,
  162.                                                     const CAEDesc& thingToCompare)
  163. {
  164.     // Compares this object to something else. This default version compares to another
  165.     // object for direct object equality. Override this for more detailed comparisons.
  166.     MScriptableObject * compareWith = thingToCompare.GetObject();
  167.     if (operation == kAEEquals)
  168.         return (compareWith == this);
  169.     return FALSE;
  170. }
  171.  
  172. //----------------------------------------------------------------------------------------
  173. // MScriptableObject::CompareProperties
  174. //----------------------------------------------------------------------------------------
  175. #pragma segment MAOSLDispatch
  176.  
  177. Boolean MScriptableObject::CompareProperties(DescType whichProperty,
  178.                                              DescType operation,
  179.                                              const CAEDesc& thingToCompare)
  180. {
  181.     // Compares a property of this object to something else. This is a generic comparison routine
  182.     // Designed to handle the most common comparison requests.
  183.  
  184.     Boolean result = FALSE;
  185.     CTempDesc theProperty;
  186.     if (this->GetObjectProperty(theProperty, whichProperty, CAEDesc::fgNullDesc))
  187.         result = theProperty.CompareDesc(thingToCompare, operation);
  188.     return result;
  189. }
  190.  
  191. //----------------------------------------------------------------------------------------
  192. // MScriptableObject::MakeObjectSpecifier
  193. //----------------------------------------------------------------------------------------
  194. #pragma segment MAOSLDispatch
  195.  
  196. Boolean MScriptableObject::MakeObjectSpecifier(CAEDesc& theObjectSpecifier,
  197.                                                DescType preferredForm)
  198. // Creates an object specifier describing this object. This calls GetObjectProperty and
  199. // GetObjectsContainer to support formName, formAbsolutePosition, and formUniqueID.
  200. // You'll only need to override this method if you want to make other forms of
  201. // object specifiers.
  202. {
  203.     CAEDesc containerSpec;
  204.     DescType containerForm = preferredForm;
  205.     MScriptableObject * theContainer = this->GetObjectsContainer();
  206.     theContainer->MakeObjectSpecifier(containerSpec, theContainer->GetSpecifierForm());
  207.     DescType myClass = this->GetOMClass();
  208.     CAEDesc formDesc;
  209.     Boolean createSpecifier = FALSE;
  210.     if (preferredForm == formName)
  211.     {
  212.         if (this->GetObjectProperty(formDesc, pName, CAEDesc::fgNullDesc))
  213.             createSpecifier = TRUE;
  214.         else
  215.             preferredForm = formAbsolutePosition; // no name, try absolute position.
  216.     }
  217.     if (preferredForm == formUniqueID)
  218.     {
  219.         if (this->GetObjectProperty(formDesc, pID, CAEDesc::fgNullDesc))
  220.             createSpecifier = TRUE;
  221.         else
  222.             preferredForm = formAbsolutePosition; // no unique ID, try absolute position.
  223.     }
  224.     if (preferredForm == formAbsolutePosition)
  225.     {
  226.         createSpecifier = this->GetObjectProperty(formDesc, pIndex, CAEDesc::fgNullDesc);
  227.     }
  228.     if (createSpecifier)
  229.         FailOSErr(CreateObjSpecifier(myClass, containerSpec, preferredForm, formDesc, TRUE, theObjectSpecifier));
  230.  
  231.     return createSpecifier;
  232. }
  233.  
  234. //----------------------------------------------------------------------------------------
  235. // MScriptableObject::GetCommandContext
  236. //----------------------------------------------------------------------------------------
  237. #pragma segment MAOSLDispatch
  238.  
  239. TCommandHandler* MScriptableObject::GetCommandContext(const CommandNumber aCommandNumber) const
  240. {
  241.     TCommandHandler *commandHandler = MA_DYNAMIC_CAST(TCommandHandler, this);
  242.     if (commandHandler)
  243.         commandHandler = commandHandler->GetContext(aCommandNumber);
  244.     
  245.     if (!commandHandler)
  246.     {
  247.         MDefaultScriptableObject *defaultTarget = TOSADispatcher::fgDispatcher->GetDefaultTarget();
  248.         
  249.         if (defaultTarget)
  250.         {
  251.             commandHandler = MA_DYNAMIC_CAST(TCommandHandler, defaultTarget);
  252.             if (commandHandler)
  253.                 commandHandler = commandHandler->GetContext(aCommandNumber);
  254.         }
  255.     }
  256.     
  257.     if (!commandHandler)    // getting desperate...
  258.         commandHandler = gDispatcher;
  259.         
  260.     return commandHandler;
  261. }
  262.  
  263. #if qOptimizeSelfSendAevt        
  264.  
  265. //----------------------------------------------------------------------------------------
  266. // MScriptableObject::IsPendingAction
  267. //----------------------------------------------------------------------------------------
  268. #pragma segment MAOSLDispatch
  269.  
  270. Boolean MScriptableObject::IsPendingAction(    const CommandNumber aCommandNumber,
  271.                                             const unsigned long actionID) const
  272. {
  273.     Boolean pending = FALSE;
  274.     
  275.     if (actionID)
  276.     {
  277.         TCommandHandler *commandHandler = this->GetCommandContext(aCommandNumber);
  278.         if (commandHandler)
  279.             pending = (actionID == commandHandler->fPendingActionID);
  280.     }
  281.     return pending;
  282. }
  283.  
  284. #endif
  285.  
  286. //----------------------------------------------------------------------------------------
  287. // MScriptableObject::HandleScriptCommand:
  288. //----------------------------------------------------------------------------------------
  289. #pragma segment MAOSLDispatch
  290.  
  291. void MScriptableObject::HandleScriptCommand(CommandNumber    aCommandNumber,
  292.                                             TAppleEvent*     message,
  293.                                             TAppleEvent*    reply)
  294. {
  295.     Boolean wasHandled = FALSE;
  296.     
  297.     TCommandHandler *commandHandler = MA_DYNAMIC_CAST(TCommandHandler, this);
  298.     if (commandHandler)
  299.     {
  300.         TBehavior *aBehavior = commandHandler->GetFirstEnabledBehavior();
  301.         if (aBehavior != NULL)
  302.             wasHandled = aBehavior->DoScriptCommand(aCommandNumber, message, reply);
  303.     }
  304.     
  305.     if (!wasHandled)
  306.         this->DoScriptCommand(aCommandNumber, message, reply);
  307. }
  308.  
  309. //----------------------------------------------------------------------------------------
  310. // MScriptableObject::DoScriptCommand
  311. //----------------------------------------------------------------------------------------
  312. #pragma segment MAOSLDispatch
  313.  
  314. void MScriptableObject::DoScriptCommand(CommandNumber     aCommandNumber,
  315.                                         TAppleEvent*     message,
  316.                                         TAppleEvent*     reply)
  317. // Aftering resolving an object specifier into an object this method is called.
  318. // Based on the command number in the refCon it dispatches the event to
  319. // one of the Core event support routines defined below.
  320. // Override this method if this object supports events beyond the core suite.
  321. {
  322.  
  323.     switch (aCommandNumber)
  324.     {
  325.         case cAEClone:
  326.             DoAEClone(message, reply);
  327.             break;
  328.  
  329.         case cAEQuit:
  330.         case cAEClose:
  331.             DoAEClose(message, reply);
  332.             break;
  333.  
  334.         case cAECountElements:
  335.             DoAECountElements(message, reply);
  336.             break;
  337.  
  338.         case cAECreateElement:
  339.             DoAECreateElement(message, reply);
  340.             break;
  341.  
  342.         case cAEDoObjectsExist:
  343.             DoAEDoObjectsExist(message, reply);
  344.             break;
  345.  
  346.         case cAEGetClassInfo:
  347.             DoAEGetClassInfo(message, reply);
  348.             break;
  349.  
  350.         case cAEGetEventInfo:
  351.             DoAEGetEventInfo(message, reply);
  352.             break;
  353.  
  354.         case cAEMove:
  355.             DoAEMove(message, reply);
  356.             break;
  357.  
  358.         case cAESetData:
  359.             DoAESetData(message, reply);
  360.             break;
  361.  
  362.         case cAEGetData:
  363.             DoAEGetData(message, reply);
  364.             break;
  365.  
  366.         case cAEGetDataSize:
  367.             DoAEGetDataSize(message, reply);
  368.             break;
  369.  
  370.         case cAEDelete:
  371.             DoAEDelete(message, reply);
  372.             break;
  373.  
  374.         case cAESave:
  375.             DoAESave(message, reply);
  376.             break;
  377.  
  378.         case cAEOpen:
  379.             DoAEOpen(message, reply);
  380.             break;
  381.  
  382.         case cAEPrint:
  383.         case cPrint:
  384.             DoAEPrint(message, reply);
  385.             break;
  386.  
  387.         default:
  388.             FailOSErr(errAEEventNotHandled);
  389.             break;
  390.     }
  391. }
  392.  
  393. //----------------------------------------------------------------------------------------
  394. // MScriptableObject::DoAEOnContainedObjects
  395. //----------------------------------------------------------------------------------------
  396. #pragma segment MAOSLDispatch
  397.  
  398. void MScriptableObject::DoAEOnContainedObjects(TScriptableObjectList* theObjectList,
  399.                                                CommandNumber aCommandNumber,
  400.                                                TAppleEvent* message,
  401.                                                TAppleEvent* reply)
  402. {
  403.     // If the AppleEvent's object specifier resolves into a list of objects, MacApp first gives
  404.     // their container object a shot at handling the event.
  405.  
  406.     // If this is a list of TPropertyAccessors and its a SetData AppleEvent, create a TSetPropertyCommand
  407.     // To do the work on all the objects
  408.     if ((aCommandNumber == cAESetData) && theObjectList->IsPropertyList())
  409.     {
  410.         DescType theProperty;
  411.         MAVolatileInit(TList*, theCmdObjectList, NULL);
  412.         MAVolatileInit(TSetPropertyCommand*, theCmd, NULL);
  413.         FailInfo fi;
  414.         Try(fi)
  415.         {
  416.             {
  417.                 theCmdObjectList = NewList();
  418.                 CObjectIterator iter(theObjectList);
  419.                 for (MScriptableObject * anObject = (MScriptableObject *)iter.FirstObject(); iter.More(); anObject = (MScriptableObject *)iter.NextObject())
  420.                 {
  421.                     TPropertyAccessor * theAccessor = (TPropertyAccessor *)anObject;
  422.                     theProperty = theAccessor->fWhichProperty;
  423.                     theCmdObjectList->InsertLast((TObject *)anObject);
  424.                 }
  425.                 theCmd = new TSetPropertyCommand;
  426.                 theCmd->ISetPropertyCommand(theProperty, theCmdObjectList, message, reply);
  427.                 theCmdObjectList = (TList *)FreeIfObject(theCmdObjectList);
  428.                 theCmd->Process();
  429.             }
  430.             fi.Success();
  431.         }
  432.         else // Recover
  433.         {
  434.             FreeIfObject(theCmd);
  435.             FreeIfObject(theCmdObjectList);
  436.             fi.ReSignal();
  437.         }
  438.     }
  439.     else
  440.         theObjectList->DoScriptCommand(aCommandNumber, message, reply);
  441. }
  442.  
  443. //----------------------------------------------------------------------------------------
  444. // MScriptableObject::DoAEClone
  445. //----------------------------------------------------------------------------------------
  446. #pragma segment MAOSLDispatch
  447.  
  448. void MScriptableObject::DoAEClone(TAppleEvent*    /* message */ ,
  449.                                   TAppleEvent* /* reply */)
  450. {
  451.     // Handle the Clone AppleEvent from the Core Suite.
  452.     FailOSErr(errAECantClone);
  453. }
  454.  
  455. //----------------------------------------------------------------------------------------
  456. // MScriptableObject::DoAEClose
  457. //----------------------------------------------------------------------------------------
  458. #pragma segment MAOSLDispatch
  459.  
  460. void MScriptableObject::DoAEClose(TAppleEvent*    /* message */ ,
  461.                                   TAppleEvent* /* reply */)
  462. {
  463.     // Handle the Close AppleEvent from the Core Suite.
  464.     FailOSErr(errAECantClose);
  465. }
  466.  
  467. //----------------------------------------------------------------------------------------
  468. // MScriptableObject::DoAECountElements
  469. //----------------------------------------------------------------------------------------
  470. #pragma segment MAOSLDispatch
  471.  
  472. void MScriptableObject::DoAECountElements(TAppleEvent* message,
  473.                                           TAppleEvent* reply)
  474. {
  475.     // Handle the Count Elements AppleEvent from the Core Suite.
  476.     DescType theClass = ((TAppleEvent *)message)->ReadType(keyAEObjectClass);
  477.     long numObjects = this->CountContainedObjects(theClass);
  478.     reply->WriteLong(keyAEResult, numObjects);
  479. }
  480.  
  481. //----------------------------------------------------------------------------------------
  482. // MScriptableObject::DoAECreateElement
  483. //----------------------------------------------------------------------------------------
  484. #pragma segment MAOSLDispatch
  485.  
  486. void MScriptableObject::DoAECreateElement(TAppleEvent*/* message */  ,
  487.                                           TAppleEvent* /* reply */)
  488. {
  489.     // Handle the Create Element AppleEvent from the Core Suite.
  490.     FailOSErr(errAECantCreate);
  491. }
  492.  
  493. //----------------------------------------------------------------------------------------
  494. // MScriptableObject::DoAEDelete
  495. //----------------------------------------------------------------------------------------
  496. #pragma segment MAOSLDispatch
  497.  
  498. void MScriptableObject::DoAEDelete(TAppleEvent*    /* message */ ,
  499.                                    TAppleEvent* /* reply */)
  500. {
  501.     // Handle the Delete AppleEvent from the Core Suite.
  502.     FailOSErr(errAECantDelete);
  503. }
  504.  
  505. //----------------------------------------------------------------------------------------
  506. // MScriptableObject::DoAEDoObjectsExist
  507. //----------------------------------------------------------------------------------------
  508. #pragma segment MAOSLDispatch
  509.  
  510. void MScriptableObject::DoAEDoObjectsExist(TAppleEvent* /* message */  ,
  511.                                            TAppleEvent* reply)
  512. {
  513.     // Handle the DoObjectsExist AppleEvent from the Core Suite.
  514.     // Of course I exist, otherwise I couldn't do this:
  515.     ((TAppleEvent *)reply)->WriteBoolean(keyAEResult, TRUE);
  516.     // If I didn't exist AccessContainedObjects would fail and that's handled 
  517.     // in TScriptEventDispatcher:DispatchAppleEvent.
  518. }
  519.  
  520. //----------------------------------------------------------------------------------------
  521. // MScriptableObject::DoAEGetClassInfo
  522. //----------------------------------------------------------------------------------------
  523. #pragma segment MAOSLDispatch
  524.  
  525. void MScriptableObject::DoAEGetClassInfo(TAppleEvent* /* message */  ,
  526.                                          TAppleEvent* /* reply */)
  527. {
  528.     // Handle the DoGetClassInfo AppleEvent from the Core Suite.
  529.     FailOSErr(errAECantGetClassInfo);
  530. }
  531.  
  532. //----------------------------------------------------------------------------------------
  533. // MScriptableObject::DoAEGetEventInfo
  534. //----------------------------------------------------------------------------------------
  535. #pragma segment MAOSLDispatch
  536.  
  537. void MScriptableObject::DoAEGetEventInfo(TAppleEvent* /* message */  ,
  538.                                          TAppleEvent* /* reply */)
  539. {
  540.     // Handle the DoGetEventInfo AppleEvent from the Core Suite.
  541.     FailOSErr(errAECantGetEventInfo);
  542. }
  543.  
  544. //----------------------------------------------------------------------------------------
  545. // MScriptableObject::DoAEGetData
  546. //----------------------------------------------------------------------------------------
  547. #pragma segment MAOSLDispatch
  548.  
  549. void MScriptableObject::DoAEGetData(TAppleEvent*/* message */  ,
  550.                                     TAppleEvent* reply)
  551. {
  552.     // Handle the GetData AppleEvent from the Core Suite.
  553.     CTempDesc theSpecifier;
  554.     MakeObjectSpecifier(theSpecifier, this->GetSpecifierForm());
  555.     reply->WriteParameter(keyAEResult, theSpecifier);
  556. }
  557.  
  558. //----------------------------------------------------------------------------------------
  559. // MScriptableObject::DoAEGetDataSize
  560. //----------------------------------------------------------------------------------------
  561. #pragma segment MAOSLDispatch
  562.  
  563. void MScriptableObject::DoAEGetDataSize(TAppleEvent* /* message */  ,
  564.                                         TAppleEvent* /* reply */)
  565. {
  566.     // Handle the GetDataSize AppleEvent from the Core Suite.
  567.     FailOSErr(errAECantGetDataSize);
  568. }
  569.  
  570. //----------------------------------------------------------------------------------------
  571. // MScriptableObject::DoAEMove
  572. //----------------------------------------------------------------------------------------
  573. #pragma segment MAOSLDispatch
  574.  
  575. void MScriptableObject::DoAEMove(TAppleEvent*    /* message */ ,
  576.                                  TAppleEvent*    /* reply */)
  577. {
  578.     // Handle the Move AppleEvent from the Core Suite.
  579.     FailOSErr(errAECantMove);
  580. }
  581.  
  582.  
  583. //----------------------------------------------------------------------------------------
  584. // MScriptableObject::DoAEOpen
  585. //----------------------------------------------------------------------------------------
  586. #pragma segment MAOSLDispatch
  587.  
  588. void MScriptableObject::DoAEOpen(TAppleEvent*    /* message */ ,
  589.                                  TAppleEvent*    /* reply */)
  590. {
  591.     // Handle the Open AppleEvent from the Core Suite.
  592.     FailOSErr(errAECantOpen);
  593. }
  594.  
  595. //----------------------------------------------------------------------------------------
  596. // MScriptableObject::DoAEPrint
  597. //----------------------------------------------------------------------------------------
  598. #pragma segment MAOSLDispatch
  599.  
  600. void MScriptableObject::DoAEPrint(TAppleEvent*    /* message */ ,
  601.                                   TAppleEvent*    /* reply */)
  602. {
  603.     // Handle the Print AppleEvent from the Core Suite.
  604.     FailOSErr(errAECantPrint);
  605. }
  606.  
  607. //----------------------------------------------------------------------------------------
  608. // MScriptableObject::DoAESave
  609. //----------------------------------------------------------------------------------------
  610. #pragma segment MAOSLDispatch
  611.  
  612. void MScriptableObject::DoAESave(TAppleEvent*    /* message */ ,
  613.                                  TAppleEvent*    /* reply */)
  614. {
  615.     // Handle the Save AppleEvent from the Core Suite.
  616.     FailOSErr(errAECantSave);
  617. }
  618.  
  619. //----------------------------------------------------------------------------------------
  620. // MScriptableObject::DoAESetData
  621. //----------------------------------------------------------------------------------------
  622. #pragma segment MAOSLDispatch
  623.  
  624. void MScriptableObject::DoAESetData(TAppleEvent*    /* message */  ,
  625.                                     TAppleEvent*    /* reply */)
  626. {
  627.     // Handle the SetData AppleEvent from the Core Suite.
  628.     FailOSErr(errAECantSetData);
  629. }
  630.  
  631. //----------------------------------------------------------------------------------------
  632. // MScriptableObject::GetContents
  633. //----------------------------------------------------------------------------------------
  634. #pragma segment MAOSLDispatch
  635.  
  636. Boolean MScriptableObject::GetContents(CAEDesc& /*theContents*/,
  637.                                         const CAEDesc& /*desiredType*/,
  638.                                         long /*propertyFlags*/)
  639. {
  640.     // Override to return the contents of this object.
  641.     // Default is "not found". 
  642.     return FALSE;
  643. }
  644.  
  645. //----------------------------------------------------------------------------------------
  646. // MScriptableObject::SetContents
  647. //----------------------------------------------------------------------------------------
  648. #pragma segment MAOSLDispatch
  649.  
  650. void MScriptableObject::SetContents(const CAEDesc& theContents)
  651. {
  652.     // Sets the contents of this object. If theContents is an AERecord,
  653.     // SetObjectProperty will be called for each property key.
  654.     if (theContents.GetDescriptorType() == typeAERecord)
  655.     {
  656.         long numProps = 0;
  657.         FailOSErr(AECountItems(theContents, &numProps));
  658.         for (long index = 1; index <= numProps; index++)
  659.         {
  660.             CTempDesc thePropData;
  661.             DescType theKey;
  662.             if (AEGetNthDesc(theContents, index, typeWildCard, &theKey, thePropData) == noErr)
  663.                 this->SetObjectProperty(thePropData, theKey);
  664.         }
  665.     }
  666. }
  667.  
  668. //----------------------------------------------------------------------------------------
  669. // MScriptableObject::GetObjectProperty
  670. //----------------------------------------------------------------------------------------
  671. #pragma segment MAOSLDispatch
  672.  
  673. Boolean MScriptableObject::GetObjectProperty(CAEDesc& thePropertyValue,
  674.                                              DescType whichProperty,
  675.                                              const CAEDesc& desiredType)
  676. {
  677.     Boolean hasProperty = TRUE;
  678.     FailInfo fi;
  679.     Try(fi)
  680.     {
  681.         // Returns default property values for this object.
  682.         switch (whichProperty)
  683.         {
  684.             case pContents:
  685.                 hasProperty = this->GetContents(thePropertyValue, desiredType);
  686.                 break;
  687.                 
  688.             case pClass:
  689.                 thePropertyValue.PutType(GetOMClass());
  690.                 break;
  691.     
  692. #if qAttachable
  693.             case pScript:
  694.                 this->GetOSAScript(thePropertyValue, desiredType);
  695.                 break;
  696. #endif
  697.             case pIndex:
  698.                 {
  699.                     hasProperty = FALSE;
  700.                     DescType myType = this->GetOMClass();
  701.                     MScriptableObject * itsContainer = this->GetObjectsContainer();
  702.                     long numObjects = itsContainer->CountContainedObjects(myType);
  703.                     for (long myIndex = 1; myIndex <= numObjects; myIndex++)
  704.                     {
  705.                         MScriptableObject * indexedObject = itsContainer->GetIndContainedObject(myType, myIndex);
  706.                         CTempDesc objectDesc;
  707.                         objectDesc.PutObject(indexedObject);
  708.                         if (this->CompareScriptableObjects(kAEEquals, objectDesc))
  709.                         {
  710.                             thePropertyValue.PutLong(myIndex);
  711.                             hasProperty = TRUE;
  712.                             break;
  713.                         }
  714.                     }
  715.                 }
  716.                 break;
  717.     
  718.             default:
  719.                 hasProperty = FALSE;
  720.                 break;
  721.         }
  722.         fi.Success();
  723.     }
  724.     else
  725.     {
  726.         hasProperty = FALSE;
  727.     }
  728.     return hasProperty;
  729. }
  730.  
  731. //----------------------------------------------------------------------------------------
  732. // MScriptableObject::SetObjectProperty
  733. //----------------------------------------------------------------------------------------
  734. #pragma segment MAOSLDispatch
  735.  
  736. void MScriptableObject::SetObjectProperty(const CAEDesc& thePropertyValue,
  737.                                           DescType whichProperty)
  738. {
  739.     // Override this method to set property values for this object.
  740.     switch (whichProperty)
  741.     {
  742. #if qAttachable
  743.         case pScript:
  744.             this->SetOSAScript(thePropertyValue);
  745.             break;
  746. #endif
  747.         case pContents:
  748.             this->SetContents(thePropertyValue);
  749.             break;
  750.  
  751.         case pClass:
  752.         case pIndex:
  753.             FailOSErr(errAECantSetReadOnly);
  754.             break;
  755.  
  756.         default:
  757.             FailOSErr(errAENoSuchObject);
  758.             break;
  759.     }
  760. }
  761.  
  762. //----------------------------------------------------------------------------------------
  763. // MScriptableObject::GetSetPropertyInfo
  764. //----------------------------------------------------------------------------------------
  765. #pragma segment MAOSLDispatch
  766.  
  767. void MScriptableObject::GetSetPropertyInfo(DescType /*whichProperty*/ ,
  768.                                            CommandNumber& cmdNum,
  769.                                            Boolean& canUndo,
  770.                                            Boolean& causesChange,
  771.                                            TCommandHandler* &theContext)
  772. {
  773.     // When an AppleEvent is received that will set a property for this object a TSetPropertyCommand
  774.     // will be created to do it. You can override this method to provide the command number and the
  775.     // canUndo and causesChange flags for the command.
  776.     cmdNum = cAESetData;
  777.     canUndo = TRUE;
  778.     causesChange = TRUE;
  779.     theContext = this->GetCommandContext(cmdNum);
  780. }
  781.  
  782. //----------------------------------------------------------------------------------------
  783. // MScriptableObject::GetContainedObject
  784. //----------------------------------------------------------------------------------------
  785. #pragma segment MAOSLDispatch
  786.  
  787. MScriptableObject* MScriptableObject::GetContainedObject(DescType desiredType,
  788.                                                          DescType selectionForm,
  789.                                                          const CAEDesc& selectionData)
  790. {
  791.     // Returns an object contained within this one. If the desiredType is a property
  792.     // of this object, we create a TPropertyAccessor and return it.
  793.     // Later on, the TPropertyAccessor can act on the properties of this object.
  794.     // For other types we try to return an object. If you would really like to reference
  795.     // something else you can create an object class that references it and return one of those.
  796.     // For each keyform this routine figures out which contained object is needed and gets it
  797.     // by calling GetIndContainedObject. If you just want to provide the OSL with access to 
  798.     // contained objects you should override GetIndContainedObject.
  799.     MScriptableObject *result = NULL;
  800.     CAEDesc theDataDesc = selectionData;
  801.     if (desiredType == cApplication)
  802.     {
  803.         result = gDispatcher;
  804.     }
  805.     else if (desiredType == cProperty)
  806.     {
  807.         DescType whichProperty = theDataDesc.GetType();
  808.         TPropertyAccessor * theAccessor = new TPropertyAccessor;
  809.         theAccessor->IPropertyAccessor(this, whichProperty);
  810.         TOSADispatcher::fgDispatcher->AddTemporaryToken(theAccessor);
  811.         result = theAccessor;
  812.     }
  813.     else
  814.     {
  815.         // Now we switch on the key forms to find the correct contained object.
  816.         switch (selectionForm)
  817.         {
  818.             case formName:
  819.                 {
  820.                     // Search through all the objects of this type and look at their pName property.
  821.                     // This is hardly the most efficient way to do this, but works in a very generic fashion.
  822.                     // If you have a lot of contained objects you can override this to look at the contained
  823.                     // objects directly.
  824.                     CStr255 keyNameStr;
  825.                     CStr255 objectNameStr;
  826.                     theDataDesc.GetString(keyNameStr, 255);
  827.                     long numObjects = this->CountContainedObjects(desiredType);
  828.                     for (long myIndex = 1; myIndex <= numObjects; myIndex++)
  829.                     {
  830.                         CTempDesc theNameDesc;
  831.                         MScriptableObject *indexedObject = GetIndContainedObject(desiredType, myIndex);
  832.                         if (indexedObject && indexedObject->GetObjectProperty(theNameDesc, pName, CAEDesc::fgNullDesc))
  833.                         {
  834.                             theNameDesc.GetString(objectNameStr, 255);
  835.                             if (IUEqualString(keyNameStr, objectNameStr) == 0)
  836.                             {
  837.                                 result = indexedObject;
  838.                                 break;
  839.                             }
  840.                         }
  841.                     }
  842.                     break;
  843.                 }
  844.  
  845.             case formRelativePosition:
  846.                 {
  847.                     DescType whichPosition = **(DescType * *)theDataDesc.GetDataHandle();
  848.                     result = this->GetAdjacentObject(desiredType, whichPosition);
  849.                     break;
  850.                 }
  851.  
  852.             case formRange:
  853.                 {
  854.                     CTempDesc rangeStart;
  855.                     CTempDesc rangeStop;
  856.                     CTempDesc rangeRecord;
  857.                     MScriptableObject * startObj = NULL;
  858.                     MScriptableObject * stopObj = NULL;
  859.                     FailOSErr(AECoerceDesc(theDataDesc, typeAERecord, rangeRecord));
  860.                     rangeRecord.GetKeyDesc(keyAERangeStart, typeObjectSpecifier, rangeStart);
  861.                     rangeRecord.GetKeyDesc(keyAERangeStop, typeObjectSpecifier, rangeStop);
  862.                     startObj = TOSADispatcher::fgDispatcher->ResolveObjectSpecifier(rangeStart);
  863.                     stopObj = TOSADispatcher::fgDispatcher->ResolveObjectSpecifier(rangeStop);
  864.                     FailNIL(startObj);
  865.                     FailNIL(stopObj);
  866.                     // Now we have the bounding objects in the range
  867.                     // Call the accessor function to get the range of contained objects
  868.                     result = GetObjectsWithinRange(desiredType, startObj, stopObj);
  869.                     break;
  870.                 }
  871.  
  872.             case formUniqueID:
  873.                 {
  874.                     CStr255 theKeyStr;
  875.                     CStr255 uniqueIDStr;
  876.                     theDataDesc.GetString(theKeyStr, 255);
  877.                     long numObjects = this->CountContainedObjects(desiredType);
  878.                     for (long myIndex = 1; myIndex <= numObjects; myIndex++)
  879.                     {
  880.                         CTempDesc theIDDesc;
  881.                         MScriptableObject *indexedObject = GetIndContainedObject(desiredType, myIndex);
  882.                         if (indexedObject && indexedObject->GetObjectProperty(theIDDesc, pID, CAEDesc::fgNullDesc))
  883.                         {
  884.                             theIDDesc.GetString(uniqueIDStr, 255);
  885.                             if (theKeyStr == uniqueIDStr)
  886.                             {
  887.                                 result = indexedObject;
  888.                                 break;
  889.                             }
  890.                         }
  891.                     }
  892.                     break;
  893.                 }
  894.  
  895.             case formAbsolutePosition:
  896.                 {
  897.                     // Gets a contained object by index. Also supports typeAbsoluteOrdinal for getting
  898.                     // objects by first, last, some, middle, and every.
  899.                     long numObjects = this->CountContainedObjects(desiredType);
  900.                     long objectIndex = 1;
  901.                     if (theDataDesc.GetDescriptorType() == typeAbsoluteOrdinal)
  902.                     {
  903.                         DescType whichType = **(DescType * *)theDataDesc.GetDataHandle();
  904.                         switch (whichType)
  905.                         {
  906.                             case kAEFirst:
  907.                                 objectIndex = 1;
  908.                                 break;
  909.                             case kAELast:
  910.                                 objectIndex = numObjects;
  911.                                 break;
  912.                             case kAEMiddle:
  913.                                 objectIndex = (numObjects + 1) / 2;
  914.                                 break;
  915.                             case kAEAny:
  916.                                 objectIndex = GetRandom(1, numObjects);
  917.                                 break;
  918.                             case kAEAll:
  919.                                 {
  920.                                     MAVolatileInit(TScriptableObjectList*, theList, new TScriptableObjectList);
  921.                                     theList->IScriptableObjectList(this);
  922.                                     FailInfo aeAllFail;
  923.                                     Try(aeAllFail)
  924.                                     {
  925.                                         for (long myIndex = 1; myIndex <= numObjects; myIndex++)
  926.                                         {
  927.                                             MScriptableObject *indexedObject = GetIndContainedObject(desiredType, myIndex);
  928.                                             if (indexedObject)
  929.                                                 theList->InsertLast((TObject *)indexedObject);
  930.                                         }
  931.                                         result = theList;
  932.                                         TOSADispatcher::fgDispatcher->AddTemporaryToken(theList);
  933.                                         aeAllFail.Success();
  934.                                     }
  935.                                     else // Recover
  936.                                     {
  937.                                         FreeIfObject(theList);
  938.                                         aeAllFail.ReSignal();
  939.                                     }
  940.                                 }
  941.                                 break;
  942.                         }
  943.                     }
  944.                     else
  945.                     {
  946.                         objectIndex = theDataDesc.GetLong();
  947.                         if (objectIndex < 0)
  948.                             objectIndex = objectIndex + numObjects + 1;
  949.                     }
  950.                     if (result == NULL)                // If the result has not been set previously
  951.                         result = GetIndContainedObject(desiredType, objectIndex);
  952.                     break;
  953.                 }
  954.  
  955.             default:
  956.                 FailOSErr(errAEEventNotHandled);     //whose clauses need errAEEventNotHandled
  957.         }
  958.     }
  959.     return result;
  960. }
  961.  
  962. //----------------------------------------------------------------------------------------
  963. // MScriptableObject::GetIndContainedObject
  964. //----------------------------------------------------------------------------------------
  965. #pragma segment MAOSLDispatch
  966.  
  967. MScriptableObject* MScriptableObject::GetIndContainedObject(DescType/*desiredType*/ ,
  968.                                                             long/*index*/)
  969. // Returns an object contained within this one based on its absolute
  970. // position within the container. If you override this method to return
  971. // contained objects MScriptableObject::GetContainedObject will use this to get
  972. // one or more objects required by the different reference forms.
  973. {
  974.     return NULL;
  975. }
  976.  
  977. //----------------------------------------------------------------------------------------
  978. // MScriptableObject::GetObjectsWithinRange
  979. //----------------------------------------------------------------------------------------
  980. #pragma segment MAOSLDispatch
  981.  
  982. MScriptableObject* MScriptableObject::GetObjectsWithinRange(DescType desiredType,
  983.                                                             MScriptableObject* startBounds,
  984.                                                             MScriptableObject* endBounds)
  985. // Returns an object or list of objects contained within this one
  986. // that lie within the startBounds object and the endBounds object.
  987. // The default method assumes that the startBounds and endBounds objects
  988. // are of the desiredType.
  989. // You can override this to provide custom range access.
  990. {
  991.     MScriptableObject * result = NULL;
  992.     long numObjects = CountContainedObjects(desiredType);
  993.     Boolean addObjects = FALSE;
  994.     MAVolatileInit(TScriptableObjectList*, theList, new TScriptableObjectList);
  995.     theList->IScriptableObjectList(this);
  996.  
  997.     FailInfo fi;
  998.     Try(fi)
  999.     {
  1000.         for (long myIndex = 1; myIndex <= numObjects; myIndex++)
  1001.         {
  1002.             MScriptableObject *indexedObject = GetIndContainedObject(desiredType, myIndex);
  1003.             CTempDesc objectDesc;
  1004.             objectDesc.PutObject(indexedObject);
  1005.             addObjects = (addObjects || (startBounds->CompareScriptableObjects(kAEEquals, objectDesc)));
  1006.             if (addObjects)
  1007.             {
  1008.                 theList->InsertLast((TObject *)indexedObject);
  1009.                 addObjects = !endBounds->CompareScriptableObjects(kAEEquals, objectDesc);
  1010.             }
  1011.         }
  1012.         TOSADispatcher::fgDispatcher->AddTemporaryToken(theList);
  1013.         result = theList;
  1014.         fi.Success();
  1015.     }
  1016.     else // Recover
  1017.     {
  1018.         FreeIfObject(theList);
  1019.         fi.ReSignal();
  1020.     }
  1021.     return result;
  1022. }
  1023.  
  1024. //----------------------------------------------------------------------------------------
  1025. // MScriptableObject::GetObjectsContainer
  1026. //----------------------------------------------------------------------------------------
  1027. #pragma segment MAOSLDispatch
  1028.  
  1029. MScriptableObject* MScriptableObject::GetObjectsContainer()
  1030. {
  1031.     // By default we'll return the application.
  1032.     return (MScriptableObject *)gDispatcher;
  1033. }
  1034.  
  1035. //----------------------------------------------------------------------------------------
  1036. // MScriptableObject::GetAdjacentObject
  1037. //----------------------------------------------------------------------------------------
  1038. #pragma segment MAOSLDispatch
  1039.  
  1040. MScriptableObject* MScriptableObject::GetAdjacentObject(DescType desiredType,
  1041.                                                         DescType position)
  1042. // When the OSL resolves relative reference forms it first specifies an object
  1043. // then asks that object for the one before or after it. This method returns
  1044. // an object of the desiredType before or after it. 
  1045. // You can override this method by to provide custom access.
  1046. {
  1047.     MScriptableObject * result = NULL;
  1048.     CTempDesc myIndex;
  1049.     if (this->GetObjectProperty(myIndex, pIndex, CAEDesc::fgNullDesc))
  1050.     {
  1051.         long relativeIndex = myIndex.GetLong();
  1052.         if (position == kAENext)
  1053.             relativeIndex++;
  1054.         else if (position == kAEPrevious)
  1055.             relativeIndex--;
  1056.         MScriptableObject * itsContainer = this->GetObjectsContainer();
  1057.         result = itsContainer->GetIndContainedObject(desiredType, relativeIndex);
  1058.     }
  1059.     return result;
  1060. }
  1061.  
  1062. //----------------------------------------------------------------------------------------
  1063. // MScriptableObject::MakeNewMarkingList
  1064. //----------------------------------------------------------------------------------------
  1065. #pragma segment MAOSLDispatch
  1066.  
  1067. TScriptableObjectList* MScriptableObject::MakeNewMarkingList()
  1068. {
  1069.     // Returns a TScriptableObjectList to use for marking objects contained within this one. 
  1070.     TScriptableObjectList * theList = new TScriptableObjectList;
  1071.     theList->IScriptableObjectList(this);
  1072.     TOSADispatcher::fgDispatcher->AddTemporaryToken((TObject *)theList);
  1073.     return theList;
  1074. }
  1075.  
  1076. //----------------------------------------------------------------------------------------
  1077. // MScriptableObject::SetProperties:
  1078. //----------------------------------------------------------------------------------------
  1079. #pragma segment MAOSLDispatch
  1080.  
  1081. void MScriptableObject::SetPropertiesFromEvent(TAppleEvent* theEvent)
  1082. {
  1083.     // Sets the properties of an object based on the data in the keyAEPropData parameter
  1084.     // of the event.
  1085.     if (theEvent)
  1086.     {
  1087.         CTempDesc propListDesc;
  1088.         if (AEGetParamDesc(&theEvent->fMessage, keyAEPropData, typeAERecord, propListDesc) == noErr)
  1089.             this->SetContents(propListDesc);
  1090.     }
  1091. }
  1092.  
  1093. #if qAttachable
  1094.  
  1095. //----------------------------------------------------------------------------------------
  1096. // Attached Scripts
  1097. //----------------------------------------------------------------------------------------
  1098.  
  1099. //----------------------------------------------------------------------------------------
  1100. // MScriptableObject::HasOSAScript:
  1101. //----------------------------------------------------------------------------------------
  1102. #pragma segment MAScriptingRes
  1103.  
  1104. Boolean MScriptableObject::HasOSAScript()
  1105. {
  1106.     return HasAppleScript() && (fOSAScript != NULL) && fOSAScript->HasOSAScript();
  1107. }
  1108.  
  1109. //----------------------------------------------------------------------------------------
  1110. // MScriptableObject::FreeOSAScript:
  1111. //----------------------------------------------------------------------------------------
  1112. #pragma segment MAOSLDispatch
  1113.  
  1114. void MScriptableObject::FreeOSAScript()
  1115. {
  1116.     if (fOSAScript != NULL)
  1117.     {
  1118.         TOSADispatcher::fgDispatcher->ScriptDetached();
  1119.         fOSAScript = NULL;    // This will free the rep object
  1120.                             // if its ref count drops to 0.
  1121.     }
  1122. }
  1123.  
  1124. //----------------------------------------------------------------------------------------
  1125. // MScriptableObject::SetOSAScript:
  1126. //----------------------------------------------------------------------------------------
  1127. #pragma segment MAOSLDispatch
  1128.  
  1129. void MScriptableObject::SetOSAScript(const CAEDesc& scriptDesc)
  1130. {
  1131.     if (HasAppleScript())
  1132.     {
  1133.         if (fOSAScript == NULL)
  1134.         {
  1135.             fOSAScript = COSAScriptCntPtr::NewOSAScript();
  1136.             TOSADispatcher::fgDispatcher->ScriptAttached();
  1137.         }
  1138.         fOSAScript->SetOSAScript(scriptDesc);
  1139.     }
  1140. }
  1141.  
  1142. //----------------------------------------------------------------------------------------
  1143. // MScriptableObject::GetOSAScript:
  1144. //----------------------------------------------------------------------------------------
  1145. #pragma segment MAOSLDispatch
  1146.  
  1147. void MScriptableObject::GetOSAScript(CAEDesc& scriptDesc,
  1148.                                         const CAEDesc& desiredType)
  1149. {
  1150.     if (HasAppleScript() && (fOSAScript != NULL))
  1151.         fOSAScript->GetOSAScript(scriptDesc, desiredType);
  1152. }
  1153.  
  1154. //----------------------------------------------------------------------------------------
  1155. // MScriptableObject::HandleOSAEvent:
  1156. //----------------------------------------------------------------------------------------
  1157. #pragma segment MAScriptingRes
  1158.  
  1159. Boolean MScriptableObject::HandleOSAEvent(CommandNumber aCommandNumber,
  1160.                                           TAppleEvent* message,
  1161.                                           TAppleEvent* reply)
  1162. {
  1163.     Boolean handled = FALSE;
  1164.     COSAScriptCntPtr tempOSAScript(fOSAScript);    // Temporary to prevent script
  1165.                                                 // from an early death.
  1166.     if (HasAppleScript() && (fOSAScript != NULL))
  1167.         handled = tempOSAScript->HandleOSAEvent(aCommandNumber, message, reply);
  1168.     
  1169.     return handled;
  1170. }
  1171.  
  1172. //----------------------------------------------------------------------------------------
  1173. // MScriptableObject::ReadOSAScript:
  1174. //----------------------------------------------------------------------------------------
  1175. #pragma segment MAOSLDispatch
  1176.  
  1177. void MScriptableObject::ReadOSAScript(TStream* aStream)
  1178. {
  1179.     if (HasAppleScript())
  1180.     {
  1181.         if (fOSAScript == NULL)
  1182.         {
  1183.             fOSAScript = COSAScriptCntPtr::NewOSAScript();
  1184.             TOSADispatcher::fgDispatcher->ScriptAttached();
  1185.         }
  1186.         fOSAScript->ReadOSAScript(aStream);
  1187.     }
  1188. }
  1189.  
  1190. //----------------------------------------------------------------------------------------
  1191. // MScriptableObject::WriteOSAScript:
  1192. //----------------------------------------------------------------------------------------
  1193. #pragma segment MAOSLDispatch
  1194.  
  1195. void MScriptableObject::WriteOSAScript(TStream* aStream,
  1196.                                        DescType asType)
  1197. {
  1198.     if (HasAppleScript() && (fOSAScript != NULL))
  1199.         fOSAScript->WriteOSAScript(aStream, asType);
  1200. }
  1201.  
  1202. //----------------------------------------------------------------------------------------
  1203. // MScriptableObject::IdleOSAScript:
  1204. //----------------------------------------------------------------------------------------
  1205. #pragma segment MAScriptingRes
  1206.  
  1207. void MScriptableObject::IdleOSAScript()
  1208. {
  1209.     COSAScriptCntPtr tempOSAScript(fOSAScript);    // Temporary to prevent script
  1210.                                                 // from an early death.
  1211.     if (HasAppleScript() && (fOSAScript != NULL))
  1212.         tempOSAScript->IdleOSAScript();
  1213. }
  1214.  
  1215. #endif // qAttachable
  1216.  
  1217. //========================================================================================
  1218. // CLASS MDefaultScriptableObject
  1219. //========================================================================================
  1220. #undef Inherited
  1221.  
  1222. #pragma segment MAScriptingRes
  1223. MA_DEFINE_CLASS_M1(MDefaultScriptableObject, MScriptableObject);
  1224.  
  1225. //----------------------------------------------------------------------------------------
  1226. // MDefaultScriptableObject::MDefaultScriptableObject
  1227. //----------------------------------------------------------------------------------------
  1228. #pragma segment ConstructorRes
  1229.  
  1230. MDefaultScriptableObject::MDefaultScriptableObject()
  1231.     : MScriptableObject(),
  1232.       fRecording(FALSE)
  1233. {
  1234. }
  1235.  
  1236. //----------------------------------------------------------------------------------------
  1237. // MDefaultScriptableObject::MDefaultScriptableObject
  1238. //----------------------------------------------------------------------------------------
  1239. #pragma segment ConstructorRes
  1240.  
  1241. MDefaultScriptableObject::MDefaultScriptableObject(DescType myClassID)
  1242.     : MScriptableObject(myClassID),
  1243.       fRecording(FALSE)
  1244. {
  1245. }
  1246.  
  1247. //----------------------------------------------------------------------------------------
  1248. // MDefaultScriptableObject destructor
  1249. //----------------------------------------------------------------------------------------
  1250. #pragma segment MADestructorRes
  1251.  
  1252. MDefaultScriptableObject::~MDefaultScriptableObject()
  1253. {
  1254. }
  1255.  
  1256. //----------------------------------------------------------------------------------------
  1257. // MDefaultScriptableObject::DoScriptCommand
  1258. //----------------------------------------------------------------------------------------
  1259. #pragma segment MAOSLDispatch
  1260.  
  1261. void MDefaultScriptableObject::DoScriptCommand(CommandNumber aCommandNumber,
  1262.                                                TAppleEvent* message,
  1263.                                                TAppleEvent* reply)
  1264. {
  1265.     switch (aCommandNumber)
  1266.     {
  1267.         case cAERecordingOn:
  1268.             fRecording = TRUE;
  1269.             break;
  1270.         
  1271.         case cAERecordingOff:
  1272.             fRecording = FALSE;
  1273.             break;
  1274.             
  1275.         default:
  1276.             MScriptableObject::DoScriptCommand(aCommandNumber, message, reply);
  1277.             break;
  1278.     }
  1279. }
  1280.  
  1281. //----------------------------------------------------------------------------------------
  1282. // End of UScriptableObject.cp
  1283.  
  1284. #pragma segment Inline
  1285.